package com.fengmc.tomcat;

import org.apache.catalina.LifecycleException;
import org.apache.catalina.startup.Tomcat;

import javax.servlet.ServletException;

public class SpringApplication {
    public static void run(){
        //创建tomcat
        Tomcat tomcat=new Tomcat();
        //设置端口
        tomcat.setPort(8080);
        try {
            //设置项目文件路径
            tomcat.addWebapp("/","F:\\");
            //启动tomcat
            tomcat.start();
            //监听关闭端口，比阻塞程序
            tomcat.getServer().await();
        } catch (ServletException e) {
            e.printStackTrace();
        } catch (LifecycleException e) {
            e.printStackTrace();
        }
    }
}
